VERSION 5.00
Begin VB.Form frmCustomer 
   Caption         =   "לקוח חדש"
   ClientHeight    =   10350
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7020
   LinkTopic       =   "Form1"
   ScaleHeight     =   10350
   ScaleWidth      =   7020
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtExtra2 
      Alignment       =   1  'Right Justify
      Height          =   405
      Left            =   840
      MultiLine       =   -1  'True
      TabIndex        =   52
      Top             =   6960
      Width           =   4695
   End
   Begin VB.TextBox txtExtra1 
      Alignment       =   1  'Right Justify
      Height          =   405
      Left            =   840
      MultiLine       =   -1  'True
      TabIndex        =   50
      Top             =   6480
      Width           =   4695
   End
   Begin VB.TextBox txtPaymentDays 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2640
      TabIndex        =   48
      Text            =   "30"
      Top             =   9000
      Width           =   735
   End
   Begin VB.ComboBox lstPaymentTerms 
      Height          =   315
      ItemData        =   "frmCustomer.frx":0000
      Left            =   3840
      List            =   "frmCustomer.frx":000A
      TabIndex        =   46
      Text            =   "מזומן"
      Top             =   9000
      Width           =   1095
   End
   Begin VB.ComboBox lstCurrency 
      Height          =   315
      ItemData        =   "frmCustomer.frx":001B
      Left            =   960
      List            =   "frmCustomer.frx":002E
      TabIndex        =   43
      Text            =   "NIS"
      Top             =   8040
      Width           =   735
   End
   Begin VB.TextBox txtCharge 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   41
      Text            =   "0.00"
      Top             =   8040
      Width           =   1095
   End
   Begin VB.ComboBox lstPriceListNum 
      Height          =   315
      ItemData        =   "frmCustomer.frx":004B
      Left            =   4200
      List            =   "frmCustomer.frx":004D
      TabIndex        =   40
      Text            =   "01"
      Top             =   8520
      Width           =   735
   End
   Begin VB.TextBox txtAccountNumber 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   3960
      TabIndex        =   36
      Top             =   5400
      Width           =   1575
   End
   Begin VB.TextBox txtBankBranch 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2640
      TabIndex        =   35
      Top             =   5400
      Width           =   615
   End
   Begin VB.ComboBox lstBanks 
      Height          =   315
      ItemData        =   "frmCustomer.frx":004F
      Left            =   240
      List            =   "frmCustomer.frx":0071
      TabIndex        =   34
      Text            =   "1-הבניה"
      Top             =   5400
      Width           =   1695
   End
   Begin VB.TextBox txtOpenBalance 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   4200
      TabIndex        =   14
      Text            =   "0.00"
      Top             =   7680
      Width           =   1335
   End
   Begin VB.TextBox txtComments 
      Alignment       =   1  'Right Justify
      Height          =   405
      Left            =   840
      MultiLine       =   -1  'True
      TabIndex        =   13
      Top             =   5880
      Width           =   4695
   End
   Begin VB.TextBox txtFax 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   12
      Top             =   4680
      Width           =   3015
   End
   Begin VB.TextBox txtPhone2 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   840
      TabIndex        =   11
      Top             =   4200
      Width           =   1815
   End
   Begin VB.TextBox txtPhone1 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   3600
      TabIndex        =   10
      Top             =   4200
      Width           =   1815
   End
   Begin VB.TextBox txtEMail 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   9
      Top             =   3720
      Width           =   3015
   End
   Begin VB.TextBox txtContactLastName 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   360
      TabIndex        =   8
      Top             =   3240
      Width           =   1815
   End
   Begin VB.TextBox txtContactFirstName 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   3600
      TabIndex        =   7
      Top             =   3240
      Width           =   1815
   End
   Begin VB.TextBox txtPostalCode 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   6
      Top             =   2640
      Width           =   1095
   End
   Begin VB.TextBox txtCity 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   4200
      TabIndex        =   5
      Top             =   2640
      Width           =   1215
   End
   Begin VB.TextBox txtAddress2 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   4
      Top             =   2160
      Width           =   3015
   End
   Begin VB.TextBox txtAddress1 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   3
      Top             =   1800
      Width           =   3015
   End
   Begin VB.TextBox txtOsekMorshe 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   2
      Top             =   1320
      Width           =   3015
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "OK"
      Height          =   375
      Left            =   1080
      TabIndex        =   15
      Top             =   9480
      Width           =   1095
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "ביטול"
      Height          =   375
      Left            =   240
      TabIndex        =   16
      Top             =   9480
      Width           =   735
   End
   Begin VB.TextBox txtBusinessName 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      TabIndex        =   1
      Top             =   840
      Width           =   3015
   End
   Begin VB.Label Label28 
      Alignment       =   1  'Right Justify
      Caption         =   "הערות3:"
      Height          =   255
      Left            =   5640
      TabIndex        =   53
      Top             =   6960
      Width           =   1215
   End
   Begin VB.Label Label21 
      Alignment       =   1  'Right Justify
      Caption         =   "הערות2:"
      Height          =   255
      Left            =   5640
      TabIndex        =   51
      Top             =   6480
      Width           =   1215
   End
   Begin VB.Label Label16 
      Alignment       =   2  'Center
      Caption         =   "+"
      Height          =   255
      Left            =   3480
      TabIndex        =   49
      Top             =   9000
      Width           =   375
   End
   Begin VB.Label Label15 
      Alignment       =   1  'Right Justify
      Caption         =   "תנאי תשלום:"
      Height          =   255
      Left            =   5160
      TabIndex        =   47
      Top             =   9000
      Width           =   1695
   End
   Begin VB.Label Label10 
      Alignment       =   1  'Right Justify
      Caption         =   "איש הקשר:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   177
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5520
      TabIndex        =   25
      Top             =   3000
      Width           =   1215
   End
   Begin VB.Line Line8 
      X1              =   6840
      X2              =   6840
      Y1              =   3120
      Y2              =   5040
   End
   Begin VB.Line Line7 
      X1              =   240
      X2              =   6840
      Y1              =   5040
      Y2              =   5040
   End
   Begin VB.Line Line6 
      X1              =   240
      X2              =   240
      Y1              =   3120
      Y2              =   5040
   End
   Begin VB.Line Line5 
      X1              =   240
      X2              =   6840
      Y1              =   3120
      Y2              =   3120
   End
   Begin VB.Line Line4 
      X1              =   2160
      X2              =   6840
      Y1              =   3000
      Y2              =   3000
   End
   Begin VB.Line Line3 
      X1              =   6840
      X2              =   6840
      Y1              =   1680
      Y2              =   3000
   End
   Begin VB.Line Line2 
      X1              =   2160
      X2              =   2160
      Y1              =   1680
      Y2              =   3000
   End
   Begin VB.Line Line1 
      X1              =   2160
      X2              =   6840
      Y1              =   1680
      Y2              =   1680
   End
   Begin VB.Label Label27 
      Alignment       =   1  'Right Justify
      Caption         =   "מחירון (כספית+מלאי):"
      Height          =   255
      Left            =   5160
      TabIndex        =   45
      Top             =   8520
      Width           =   1695
   End
   Begin VB.Label Label26 
      Alignment       =   1  'Right Justify
      Caption         =   "מטבע:"
      Height          =   255
      Left            =   1560
      TabIndex        =   44
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label Label25 
      Alignment       =   1  'Right Justify
      Caption         =   "מחיר לשעת עבודה (עבור כספית+יועצים):"
      Height          =   255
      Left            =   3720
      TabIndex        =   42
      Top             =   8160
      Width           =   3135
   End
   Begin VB.Label Label23 
      Alignment       =   1  'Right Justify
      Caption         =   "סניף:"
      Height          =   255
      Left            =   3000
      TabIndex        =   39
      Top             =   5400
      Width           =   735
   End
   Begin VB.Label Label24 
      Alignment       =   1  'Right Justify
      Caption         =   "בנק:"
      Height          =   255
      Left            =   1680
      TabIndex        =   38
      Top             =   5400
      Width           =   735
   End
   Begin VB.Label Label22 
      Alignment       =   1  'Right Justify
      Caption         =   "מספר חשבון:"
      Height          =   255
      Left            =   5640
      TabIndex        =   37
      Top             =   5400
      Width           =   1215
   End
   Begin VB.Label Label20 
      Alignment       =   1  'Right Justify
      Caption         =   "יתרת פתיחה:"
      Height          =   255
      Left            =   5640
      TabIndex        =   33
      Top             =   7680
      Width           =   1215
   End
   Begin VB.Label Label19 
      Alignment       =   1  'Right Justify
      Caption         =   "הערות:"
      Height          =   255
      Left            =   5640
      TabIndex        =   32
      Top             =   5880
      Width           =   1215
   End
   Begin VB.Label Label18 
      Alignment       =   1  'Right Justify
      Caption         =   "1. הכנס את פרטי הלקוח:"
      Height          =   255
      Left            =   3720
      TabIndex        =   31
      Top             =   480
      Width           =   3015
   End
   Begin VB.Label Label17 
      Alignment       =   1  'Right Justify
      Caption         =   "2. לחץ על OK. המפתח הזר ינתן אוטומטית והוא מבוסס על שעת היום."
      Height          =   495
      Left            =   2640
      TabIndex        =   30
      Top             =   9480
      Width           =   4335
   End
   Begin VB.Label Label14 
      Alignment       =   1  'Right Justify
      Caption         =   "פקס:"
      Height          =   255
      Left            =   5520
      TabIndex        =   29
      Top             =   4680
      Width           =   1215
   End
   Begin VB.Label Label13 
      Alignment       =   1  'Right Justify
      Caption         =   "טלפון 2:"
      Height          =   255
      Left            =   2280
      TabIndex        =   28
      Top             =   4200
      Width           =   1215
   End
   Begin VB.Label Label12 
      Alignment       =   1  'Right Justify
      Caption         =   "טלפון 1:"
      Height          =   255
      Left            =   5520
      TabIndex        =   27
      Top             =   4200
      Width           =   1215
   End
   Begin VB.Label Label11 
      Alignment       =   1  'Right Justify
      Caption         =   "מייל:"
      Height          =   255
      Left            =   5520
      TabIndex        =   26
      Top             =   3720
      Width           =   1215
   End
   Begin VB.Label Label9 
      Alignment       =   1  'Right Justify
      Caption         =   "שם משפחה:"
      Height          =   255
      Left            =   2280
      TabIndex        =   24
      Top             =   3240
      Width           =   1215
   End
   Begin VB.Label Label8 
      Alignment       =   1  'Right Justify
      Caption         =   "שם פרטי:"
      Height          =   375
      Left            =   5520
      TabIndex        =   23
      Top             =   3240
      Width           =   1215
   End
   Begin VB.Label Label7 
      Alignment       =   1  'Right Justify
      Caption         =   "מיקוד:"
      Height          =   255
      Left            =   3600
      TabIndex        =   22
      Top             =   2640
      Width           =   495
   End
   Begin VB.Label Label6 
      Alignment       =   1  'Right Justify
      Caption         =   "עיר:"
      Height          =   255
      Left            =   5760
      TabIndex        =   21
      Top             =   2640
      Width           =   975
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      Caption         =   "כתובת 2:"
      Height          =   255
      Left            =   5760
      TabIndex        =   20
      Top             =   2160
      Width           =   975
   End
   Begin VB.Label Label4 
      Alignment       =   1  'Right Justify
      Caption         =   "כתובת 1:"
      Height          =   255
      Left            =   5760
      TabIndex        =   19
      Top             =   1800
      Width           =   975
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Caption         =   "מספר ע""מ:"
      Height          =   255
      Left            =   5760
      TabIndex        =   18
      Top             =   1320
      Width           =   975
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "שם העסק:"
      Height          =   255
      Left            =   5760
      TabIndex        =   17
      Top             =   840
      Width           =   975
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "טופס יצירת לקוח"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   177
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4320
      TabIndex        =   0
      Top             =   0
      Width           =   2415
   End
End
Attribute VB_Name = "frmCustomer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const MOD_NAME = "frmCustomer."

Private Sub cmdCancel_Click()
10    On Error Resume Next
20        Unload Me
End Sub

Private Sub cmdOK_Click()
      Const FUNC_NAME = MOD_NAME & "cmdOK_Click"
10    On Error GoTo func_err
          
          Dim iCustomersID As Long
          Dim objCaspit As CaspitAPI.Caspit
          Dim iPaymentDays As Long
          Dim iPaymentTermsID As Long
          
20        If Len(txtBusinessName) = 0 Then
30            MyErrMsgBox "חובה למלא את שם העסק"
40            Exit Sub
50        End If
          
          Dim iBankID As Long
60        If Len(lstBanks.Text) > 0 Then iBankID = Split(lstBanks.Text, "-")(0)
          
70        iPaymentDays = CLng(txtPaymentDays)
80        iPaymentTermsID = lstPaymentTerms.ItemData(lstPaymentTerms.ListIndex)
          
          'Create the customer
90        Set objCaspit = New CaspitAPI.Caspit
100       With objCaspit
110           .CaspitPath = g_strCaspitPath
120           .AccessPath = g_strAccessPath
130           .BusinessID = g_iBusinessID
140           .DebugMode = g_blnDebug
150       End With
          
          
          'Send 0 in the CustomerNumber parameter so that the API will automaticly assign the number
160       iCustomersID = objCaspit.CreateCustomer(txtBusinessName, txtOsekMorshe, _
              txtContactFirstName, txtContactLastName, _
              txtAddress1, txtAddress2, txtCity, txtPostalCode, _
              txtPhone1, txtPhone2, txtFax, txtEMail, _
              txtComments, CCur(txtOpenBalance), _
              txtAccountNumber, txtBankBranch, iBankID, _
              lstPriceListNum.ItemData(lstPriceListNum.ListIndex), CCur("0" & txtCharge), lstCurrency, _
              CStr(CDbl(Now)), iPaymentTermsID, iPaymentDays, 0, Me.txtExtra1, Me.txtExtra2)
          
170       MyMsgBox "הלקוח נוצר בהצלחה. שם הלקוח: " & txtBusinessName & ". מספר הלקוח: " & iCustomersID
          
180       Set objCaspit = Nothing
190   Exit Sub

func_err:
200       Set objCaspit = Nothing
210       MyErrMsgBox "Error " & Err.Number & " in " & FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source & ": " & Err.Description
End Sub


Private Sub Form_Load()
      Const FUNC_NAME = MOD_NAME & "Form_Load"
10    On Error GoTo func_err
    
20      Call PopulatePriceList

25  lstPaymentTerms.ListIndex = 1
26  lstPriceListNum.ListIndex = 1

30    Exit Sub
func_err:
40        MyErrMsgBox "Error " & Err.Number & " in " & FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source & ": " & Err.Description
End Sub
Sub PopulatePriceList()
      Const FUNC_NAME = MOD_NAME & "PopulatePriceList"
10    On Error GoTo func_err
        Dim V1
        Dim objCaspit As CaspitAPI.Caspit
        Dim objPriceList As CaspitAPI.PriceList
        Dim I As Long
          
20        Set objCaspit = New CaspitAPI.Caspit
          
30        With objCaspit
40            .CaspitPath = g_strCaspitPath
50            .AccessPath = g_strAccessPath
60            .BusinessID = g_iBusinessID
70            .DebugMode = g_blnDebug
80        End With
        
90        V1 = objCaspit.GetPriceLists()
          
100       For I = 0 To UBound(V1)
110             Set objPriceList = V1(I)
120             lstPriceListNum.AddItem objPriceList.ListID & "-" & Abs(objPriceList.ListNum Mod 10000), I
130             lstPriceListNum.ItemData(I) = objPriceList.ListID

140       Next
          
150       Set objCaspit = Nothing
160   Exit Sub

func_err:
170       Set objCaspit = Nothing
180       Err.Raise Err.Number, FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source, Err.Description
End Sub

